package com.linq.cool.api.factory;

import com.linq.cool.api.domain.BeautyMember;
import com.linq.cool.api.dto.BeautyMemberBindDTO;
import com.linq.cool.api.dto.BeautyMemeberRegisterDTO;
import com.linq.cool.api.feign.RemoteBeautyMemberService;
import com.linq.cool.api.vo.WeChatLoginUser;
import com.linq.cool.api.vo.WebLoginUser;
import com.linq.cool.common.core.domain.Result;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author: yqlin
 * @Date: 2021/1/17 05:11
 * @Description: 用户服务降级处理
 * @Version: 1.0.0
 */
@Slf4j
@Component
public class RemoteBeautyMemverFallbackFactory implements FallbackFactory<RemoteBeautyMemberService> {
    @Override
    public RemoteBeautyMemberService create(Throwable throwable) {
        log.error("会员服务调用失败{}", throwable.getMessage());
        return new RemoteBeautyMemberService() {

            @Override
            public Result<WeChatLoginUser> getMemberInfo(String openId) {
                return Result.fail("获取会员信息失败");
            }

            @Override
            public Result<WebLoginUser> getFrontMemberInfo(String phone) {
                return Result.fail("获取会员信息失败");
            }

            @Override
            public Result<?> wxRegister(BeautyMember customer) {
                return Result.fail("注册会员信息失败");
            }

            @Override
            public Result<?> frontRegister(BeautyMemeberRegisterDTO dto) {
                return Result.fail("注册会员信息失败");
            }

            @Override
            public Result<BeautyMember> bindMember(BeautyMemberBindDTO dto) {
                return Result.fail("绑定手机号失败");
            }
        };
    }
}
